<?php
namespace Admin\Controller;

class AdminerController extends CommonController{
	
    public function edit_pass(){
    	if(IS_POST){
    		$curModel = D('Customer');
    		$data = I('post.info');
    		if (false === $curModel->create($data)) $this->error($curModel->getError());
    
    		$old_pass = md5($data['old_password']);
    		$user_info = $curModel->where("username='{$this->customer['username']}' and password='$old_pass' and dele_status='1'")->find();
    		if(empty($user_info))$this->error('原密码错误！');
    
    		$nickname = trim($data['my_nickname']);
    		$new_pass = md5($data['new_password']);
    
    		$res = $curModel->save(array('id'=>$this->customer['id'],'nickname'=>$nickname,'password'=>$new_pass));
    		$res ? $this->success("修改成功！") : $this->error("修改失败！");
    	}else{
    		$this->display();
    	}
    }
    
}
